import React from 'react';
import { connect } from 'dva';
import { routerRedux } from 'dva/router';
import { ActivityIndicator } from 'antd-mobile';
import Login from './pages/login';

function Index({ dispatch, loading, login }) {

  const { info } = login;
  const loginProps = {
    onLogin(data){
      dispatch({
        type: 'login/postLogin',
        payload: {
          data
        }
      })
    },
    onRegisterView(){
      // console.log(12345);
      dispatch(routerRedux.push('/register'));
    }
  }
  return (
    <div>
      <Login {...loginProps}/>
      <ActivityIndicator
        toast
        text=""
        animating={loading}
      />
    </div>
  );
}

Index.propTypes = {
};

function ribStateToProps(state, ownProps){
  return {
    loading: state.loading.global,
    login: state.login
  }
}

export default connect(ribStateToProps)(Index);
